#ifndef _SOCKET_HANDLER_H_20160315_
#define _SOCKET_HANDLER_H_20160315_

#include <string.h>
#include <string>
using std::string;

#define LISNTENQ	5
#define MAXSIZE     1024

class SocketHandler
{
private:
	int listenFd;
	//int connectFd;
	
	string ip;
	unsigned int port;

public:
	SocketHandler(string i, unsigned int p):
		listenFd(0), ip(i), port(p){}
	//绑定ip，port
	bool SocketBind();
	//listen
	bool SocketListen();
	//UINIT
	void SocketUinit();
	//读处理
	string DoRead(int fd);
	//写处理
	bool DoWrite(int fd, string str);
	//处理接收到的连接
	int HandlerAccept();
	
	int GetListenFd(){return listenFd;}
};

#endif
